package demo1;

import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.core.Size;
import org.opencv.highgui.HighGui;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.imgproc.Imgproc;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86185
 * Date: 2023-04-07
 * Time: 19:23
 */
public class SmoothFilter {
    static {
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
    }

    /**
     * 高斯滤波
     * @param args
     */
    public static void main4(String[] args) {
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
        Mat src = Imgcodecs.imread("lena.jpg");
        HighGui.imshow("src", src);
        HighGui.waitKey(0);
        Mat dst = new Mat();
        Imgproc.GaussianBlur(src, dst, new Size(5,5), 10,10);//高斯滤波
        HighGui.imshow("dst", dst);
        HighGui.waitKey(0);
    }

    /**
     * 中值滤波
     * @param args
     */
    public static void main2(String[] args) {
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
        Mat src = Imgcodecs.imread("lena.jpg");
        HighGui.imshow("src", src);
        HighGui.waitKey(0);

        Mat dst = new Mat();
        Imgproc.medianBlur(src, dst, 5);//中值滤波
        HighGui.imshow("dst",dst);
        HighGui.waitKey(0);
    }

    /**
     * 均值滤波
     * @param args
     */
    public static void main(String[] args) {
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
        Mat src = Imgcodecs.imread("lena.jpg");
        HighGui.imshow("src", src);
        HighGui.waitKey(0);

        Mat dst = new Mat();
        Imgproc.blur(src, dst, new Size(5,5));//均值滤波//卷积核越大，图片越模糊
        HighGui.imshow("dst", dst);
        HighGui.waitKey(0);
    }
}
